<template>
    <div>
    <el-row>
        <b>当前进度：</b>
        <el-radio-group v-model="radio1" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">待分配工单</el-radio-button>
        <el-radio-button label="2">待确认工单</el-radio-button>
        <el-radio-button label="3">待处理</el-radio-button>
        <el-radio-button label="4">已完成</el-radio-button>
        </el-radio-group>
    </el-row>
    <el-row>
        <b>反馈类型：</b>
        <el-radio-group v-model="radio2" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">投诉</el-radio-button>
        <el-radio-button label="2">建议</el-radio-button>
        </el-radio-group>
    </el-row>
    <el-row>
        <b>反馈分类：</b>
        <el-radio-group v-model="radio3" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">卫生</el-radio-button>
        <el-radio-button label="2">噪音</el-radio-button>
        <el-radio-button label="3">服务态度</el-radio-button>
        <el-radio-button label="4">违建</el-radio-button>
        <el-radio-button label="5">占用消防通道</el-radio-button>
        <el-radio-button label="6">小区设施</el-radio-button>
        <el-radio-button label="7">其他</el-radio-button>
        </el-radio-group>
    </el-row>
    <el-row>
        <b>工单来源：</b>
        <el-radio-group v-model="radio4" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">业主上报</el-radio-button>
        <el-radio-button label="2">公司指派</el-radio-button>
        </el-radio-group>
    </el-row>

        <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="description"
        label="问题描述">
      </el-table-column>
      <el-table-column
        prop="feedbackType"
        label="反馈类型">
        <template slot-scope="scope">
            <el-tag :type="scope.row.tagColor">{{ scope.row.feedbackType==1?"建议":"投诉" }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="feedbackClassification"
        label="反馈分类">
        <template slot-scope="scope">
            <el-tag type="" style="background-color: #e54d42; color: white;" v-if="scope.row.feedbackClassification == 1">卫生</el-tag>
            <el-tag type="" style="background-color: #f37b1d; color: white;" v-if="scope.row.feedbackClassification == 2">噪音</el-tag>
            <el-tag type="" style="background-color: #fbbd08; color: white;" v-if="scope.row.feedbackClassification == 3">服务态度</el-tag>
            <el-tag type="" style="background-color: #8dc63f; color: white;" v-if="scope.row.feedbackClassification == 4">违建</el-tag>
            <el-tag type="" style="background-color: #39b54a; color: white;" v-if="scope.row.feedbackClassification == 5">占用消防通道</el-tag>
            <el-tag type="" style="background-color: #1cbbb4; color: white;" v-if="scope.row.feedbackClassification == 6">小区设施</el-tag>
            <el-tag type="" style="background-color: #0081ff; color: white;" v-if="scope.row.feedbackClassification == 7">其他</el-tag>
        </template>    
      </el-table-column>
      <el-table-column
        prop="progress"
        label="当前进度">
       <template slot-scope="scope">
            <el-tag type="" v-if="scope.row.progress == 1"> 待分配工单 </el-tag>
            <el-tag type="info" v-if="scope.row.progress == 2">待确认工单 </el-tag>
            <el-tag type="warning" v-if="scope.row.progress == 3"> 待处理 </el-tag>
            <el-tag type="success" v-if="scope.row.progress == 4"> 已完成 </el-tag>
        </template>       
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="申请时间">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-search" @click="ToFeedbackInfo(scope.row.id)" >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
    </div>
</template>

<script>

export default {
    name:'feedback',
    data(){
        return{
            radio1: "0",
            radio2: "0",
            radio3: "0",
            radio4: "0",
            tableData: [],
            currentPage:1,
            pageSize:10,
            total:0,
        }
    },
    created(){
        this.initAuthority()
    },
    methods:{
        initAuthority(){
        this.$request.get("/role/authority",{
          params:{
            id: JSON.parse(localStorage.getItem("admin")).id,
            index: 6
          }
        })
        .then(res =>{
          this.Authority = res.data
          if(res.data == '1'){
            this.initTable()
          }else{
            this.$message.error("你没有权限访问此功能")
            // this.$router.push("/")
          }
        })
        .catch(err =>{
          console.log(err)
        })

      },
        ToFeedbackInfo(id){
           this.$router.push({
            path: 'feedbackInfo',
            query:{
                feedbackId:id
            }
           })
        },

         handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.pageSize = val
            this.initTable()
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.currentPage = val
            this.initTable()
        },
        initTable(){
            this.$request.get("/feedback/page",{
                params:{
                    page: this.currentPage,
                    size: this.pageSize,
                    progress:this.radio1,
                    feedbackType:this.radio2,
                    feedbackClassification:this.radio3,
                    source:this.radio4,
                }
            }).then(res => {
                this.tableData = res.data.records
                this.total = res.data.total
            }).catch(err =>{
                console.log(err)
            })
        },
    }
}
</script>

<style>
    .el-row{
        margin-bottom: 20px;
    }
</style>